<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style>
	.weui-media-box__hd img{
		width: 100%;
		height: 100%;
	}
	.my-bar-div {
		width:100%;
		text-align: center;
		margin-top: 5px; 
	}
</style>
<title>订单列表</title>
<jsp:include page="header.jsp"></jsp:include>
</head>
<body ontouchstart>
<div class='weui-content'>
<c:choose>
<c:when test="${not empty list}">
	<c:forEach var="app" items="${list}" varStatus="st">
        <div class="weui-panel weui-panel_access">
          <div class="weui-panel__hd"><span>单号：${app.id}</span><span class="ord-status-txt-ts fr">
          	<c:if test="${app.orderState eq '1'}">
	   			未支付
	   			</c:if>
	   			<c:if test="${app.orderState eq '2'}">
	   			未审核
	   			</c:if>
	   			<c:if test="${app.orderState eq '3'}">
	   			已审核
	   			</c:if>
	   			<c:if test="${app.orderState eq '4'}">
	   				未发货
	   			</c:if>
	   			<c:if test="${app.orderState eq '5'}">
	   				已发货
	   			</c:if>
	   			<c:if test="${app.orderState eq '6'}">
	   				已发货
	   			</c:if>
	   			<c:if test="${app.orderState eq '7'}">
	   				已退款
	   			</c:if>
	   			<c:if test="${app.orderState eq '8'}">
	   				未通过审核
	   			</c:if>
          </span></div>
          <div class="weui-media-box__bd  pd-10">
            <div class="weui-media-box_appmsg ord-pro-list" onclick="myDetail('${app.id}')">
              <div class="weui-media-box__hd"><a href="javascript:;"><img class="weui-media-box__thumb" src="${pageContext.request.contextPath }${app.goodsPic}" alt=""></a></div>
              <div class="weui-media-box__bd">
                <h1 class="weui-media-box__desc"><a href="javascript:;" class="ord-pro-link">${app.goodsName}</a></h1>
                <div class="clear mg-t-10">
                  <div class="wy-pro-pri fl">¥<em class="num font-15">${app.orderPrice}</em></div>
                  <div class="pro-amount fr"><span class="font-13">数量×<em class="name">${app.orderSum}</em></span></div>
                </div>
              </div>
            </div>
          </div>
          <div class="ord-statistics">
            <span class="wy-pro-pri">总金额：¥<em class="num font-15">${app.orderPrice*app.orderSum}</em></span>
          </div>
          <div class="weui-panel__ft">
            <div class="weui-cell weui-cell_access weui-cell_link oder-opt-btnbox">
            <c:if test="${app.orderState eq 1}">
              <a href="javascript:;" class="ords-btn-dele" onclick="myDel('${app.id}')">删除订单</a>
              <a href="javascript:;" class="ords-btn-dele" onclick="myPay('${app.id}')">去支付</a>
            </c:if>
            <c:if test="${app.orderState eq 2}">
              <a href="javascript:;" class="ords-btn-dele" onclick="myTui('${app.id}')">退款</a>
            </c:if>
            <c:if test="${app.orderState eq 8}">
              <a href="javascript:;" class="ords-btn-dele" onclick="reUpload('${app.id}')">重新上传处方</a>
              <a href="javascript:;" class="ords-btn-dele" onclick="myTui('${app.id}')">退款</a>
            </c:if>
             <c:if test="${app.orderState eq 5}">
              <a href="/phone/orderDetail?id=${app.id}" class="ords-btn-dele">确认收货</a>
            </c:if>
            <c:if test="${app.orderState eq 3}">
            	<a href="javascript:;" class="ords-btn-dele" onclick="myCode('${app.id}')">查看取货二维码</a>
            </c:if>
            </div>    
          </div>
        </div>
        </c:forEach>
        </c:when>
<c:otherwise>
	<div class="my-bar-div">没有订单信息!</div>
</c:otherwise>
</c:choose>
</div>
<jsp:include page="foot.jsp"></jsp:include>
<script>
//订单删除
function myDel(id){
	var url ="/phone/orderDel?id="+id;
	$.get(url,function(data){
		if("ok"==data){
			$.toast("订单删除成功!","text");
			window.location.reload();
		}else{
			$.alert("订单删除失败!");
		}
	});
}
//支付
function myPay(id){
	var url ="/phone/orderPay?id="+id;
	window.location.href=url;
}

//退款
function myTui(id){
	$.confirm("你确定要退款吗？", function() {
		var url="/phone/tuiSure?orderId="+id;
		window.location.href=url;
		  }, function() {
		  $.alert("退款已经取消!");
		  });
	}
	//获取二维码
	function myCode(id){
		var url ="/phone/getCode?id="+id;
		window.location.href=url;
	}
	
	function myDetail(id){
		var url ="/phone/orderDetail?id="+id;
		window.location.href=url;
	}
	//重新上传处方
	function reUpload(id){
		var url ="/phone/reChufang?id="+id;
		window.location.href=url;
	}
</script>
</body>
</html>